package com.hdu.feignInterceptor;

import com.hdu.context.FullLinkContext;
import com.hdu.context.FullLinkContextHolder;
import feign.RequestInterceptor;
import feign.RequestTemplate;

import java.util.Objects;

import static com.hdu.constant.FullLinkConstant.FULL_LINK_STRESS_HEADER;
import static com.hdu.constant.FullLinkConstant.IS_FULL_LINK_STRESS;

public class FeignFullLinkInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        FullLinkContext fullLinkContext = FullLinkContextHolder.getFullLinkContext();
        if (Objects.nonNull(fullLinkContext)) {
            requestTemplate.header(FULL_LINK_STRESS_HEADER, IS_FULL_LINK_STRESS);
        }
    }
}
